<template>
  <div class="app-container">
    <!-- <strong>讲师列表</strong> -->
    <!--查询表单-->
    <el-form :inline="true" class="demo-form-inline">

      <el-form-item>
        <el-input v-model="perQuery.name" placeholder="教师名"/>
      </el-form-item>

      <el-form-item>
        <el-select v-model="perQuery.state" clearable placeholder="总评生成状态">
          <el-option :value="'尚未生成'" label="尚未生成"/>
          <el-option :value="'已生成'" label="已生成"/>
        </el-select>
      </el-form-item>

      <el-button type="primary" icon="el-icon-search" @click="getList()">查询</el-button>
      <el-button type="default" @click="resetData()">清空</el-button>
    </el-form>

    <!-- 表格 -->
    <el-table
      :data="list"
      style="width: 100%"
    >
      <el-table-column
        label="序号"
        width="70"
        align="center"
      >
        <template slot-scope="scope">
          {{ (page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column label="教师姓名" prop="name" align="center"/>

      <el-table-column label="账号状态" prop="disable" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.disable === '0'">已禁用</span>
          <span v-if="scope.row.disable === '1'">正常</span>
        </template>

      </el-table-column>

      <el-table-column label="教学表现" prop="performance" align="center"/>

      <el-table-column label="提交材料次数" prop="count" align="center"/>

      <el-table-column label="材料通过次数" prop="passesNumber" align="center"/>

      <el-table-column label="立项数" prop="madeApp" align="center"/>

      <el-table-column label="总评分数" prop="commentScore" align="center"/>

      <el-table-column label="总评生成状态" prop="state" align="center">
        <template slot-scope="scope">
          <span :style="{ color: scope.row.state === '尚未生成' ? 'red' : 'brown' }">{{ scope.row.state }}</span>
        </template>
      </el-table-column>

      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">

<!--          <el-button type="text" size="4px" icon="el-icon-edit" class="edit-button" @click="outReview(scope.row.id)">打回</el-button>-->
          <el-button type="text" size="4px" icon="el-icon-circle-check" class="disable-button" @click="okReview(scope.row.id)"><strong>生成总评</strong></el-button>
        </template>
      </el-table-column>

    </el-table>

    <!-- 分页 -->
    <el-pagination
      :current-page="page"
      :page-size="limit"
      :total="total"
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="getList"
    />


  </div>
</template>

<script>
// import teacher from '@/api/adm/teacherAdmin'
// import * as teacher from '@/api/adm/teacherAdmin'
import * as admin from '@/api/super/admin'
export default {
  data() {
    return {
      list: null, // 查询之后接口返回集合
      page: 1, // 当前页
      limit: 10, // 每页记录数
      total: 0, // 总记录数
      perQuery: {} // 条件封装对象
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 条件查询教师信息
    getList(page = 1) {
      this.page = page
      admin.madeGenApp(this.page, this.limit, this.perQuery)
        .then(response => {
          // 请求成功
          // response接口返回的数据
          // console.log(response)
          this.list = response.data.rows

          this.total = response.data.total
          console.log(this.list)
          console.log(this.total)
        })
    },

    //清空要查询的内容
    resetData() {
      this.perQuery = {}
      this.getList()
    },
    //生成总评
    okReview(id){
      admin.okmadeGenApp(id).then(response => {
        this.$message({
          type: 'success',
          message: '提交成功'
        });
        this.getList()
      })
    },




  }
}
</script>
<style>
.demo-table-expand {
  font-size: 0;
}

.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}

.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}

.edit-button {
  color: rgb(189, 142, 67); /* 紫色 */
}

.disable-button {
  color: #6ebf00; /* 蓝色 */
  font-size: 15px;
}

.delete-button {
  color: rgb(255, 140, 140); /* 红色 */
}
</style>
